<template>
  <div class="debug-btn" @click="debugHandle" />
</template>
<script>
import Vconsole from 'vconsole'
export default {
  data() {
    return {
      count: 0
    }
  },
  methods: {
    debugHandle() {
      this.count += 1
      if (this.count >= 5) {
        if (!document.getElementById('__vconsole')) {
          new Vconsole()
          document.getElementById('__vconsole').style.display =
                        'block'
          this.count = 0
          return
        }
        const vconsoleDisplay = document.getElementById('__vconsole')
          .style.display
        document.getElementById('__vconsole').style.display =
                    vconsoleDisplay === 'block' ? 'none' : 'block'
        this.count = 0
        return
      }
      if (this.count === 1) {
        const timer = setTimeout(() => {
          this.count = 0
          clearTimeout(timer)
        }, 4000)
      }
    }
  }
}
</script>
<style lang="less" scoped>
.debug-btn {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 30px;
    height: 30px;
    background-color: transparent;
    z-index: 99999;
}
</style>
